package org.fisco.bcos.evidence.contract;

import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

import org.fisco.bcos.sdk.abi.FunctionReturnDecoder;
import org.fisco.bcos.sdk.abi.TypeReference;
import org.fisco.bcos.sdk.abi.datatypes.Bool;
import org.fisco.bcos.sdk.abi.datatypes.Event;
import org.fisco.bcos.sdk.abi.datatypes.Function;
import org.fisco.bcos.sdk.abi.datatypes.Type;
import org.fisco.bcos.sdk.abi.datatypes.Utf8String;
import org.fisco.bcos.sdk.abi.datatypes.generated.Int256;
import org.fisco.bcos.sdk.abi.datatypes.generated.tuples.generated.Tuple1;
import org.fisco.bcos.sdk.abi.datatypes.generated.tuples.generated.Tuple5;
import org.fisco.bcos.sdk.client.Client;
import org.fisco.bcos.sdk.contract.Contract;
import org.fisco.bcos.sdk.crypto.CryptoSuite;
import org.fisco.bcos.sdk.crypto.keypair.CryptoKeyPair;
import org.fisco.bcos.sdk.eventsub.EventCallback;
import org.fisco.bcos.sdk.model.CryptoType;
import org.fisco.bcos.sdk.model.TransactionReceipt;
import org.fisco.bcos.sdk.model.callback.TransactionCallback;
import org.fisco.bcos.sdk.transaction.model.exception.ContractException;

@SuppressWarnings("unchecked")
public class AccountKV extends Contract {
    public static final String[] BINARY_ARRAY = {"608060405234801561001057600080fd5b506110106000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166356004b6a6040805190810160405280600a81526020017f6b765f6163636f756e74000000000000000000000000000000000000000000008152506040518263ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040180806020018060200180602001848103845285818151815260200191508051906020019080838360005b8381101561013957808201518184015260208101905061011e565b50505050905090810190601f1680156101665780820380516001836020036101000a031916815260200191505b50848103835260028152602001807f6964000000000000000000000000000000000000000000000000000000000000815250602001848103825260258152602001807f6964656e746974792c6e616d652c6163636f756e74547970652c6163636f756e81526020017f7448617368000000000000000000000000000000000000000000000000000000815250604001945050505050602060405180830381600087803b15801561021557600080fd5b505af1158015610229573d6000803e3d6000fd5b505050506040513d602081101561023f57600080fd5b810190808051906020019092919050505050611525806102606000396000f30060806040526004361061004c576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680631a0b8d5514610051578063693ec85e146101e6575b600080fd5b34801561005d57600080fd5b506101d0600480360381019080803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290505050610417565b6040518082815260200191505060405180910390f35b3480156101f257600080fd5b5061024d600480360381019080803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290505050610d69565b604051808615151515815260200180602001806020018060200180602001858103855289818151815260200191508051906020019080838360005b838110156102a3578082015181840152602081019050610288565b50505050905090810190601f1680156102d05780820380516001836020036101000a031916815260200191505b50858103845288818151815260200191508051906020019080838360005b838110156103095780820151818401526020810190506102ee565b50505050905090810190601f1680156103365780820380516001836020036101000a031916815260200191505b50858103835287818151815260200191508051906020019080838360005b8381101561036f578082015181840152602081019050610354565b50505050905090810190601f16801561039c5780820380516001836020036101000a031916815260200191505b50858103825286818151815260200191508051906020019080838360005b838110156103d55780820151818401526020810190506103ba565b50505050905090810190601f1680156104025780820380516001836020036101000a031916815260200191505b50995050505050505050505060405180910390f35b6000806000806000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663f23f63c96040805190810160405280600a81526020017f6b765f6163636f756e74000000000000000000000000000000000000000000008152506040518263ffffffff167c01000000000000000000000000000000000000000000000000000000000281526004018080602001828103825283818151815260200191508051906020019080838360005b838110156104fb5780820151818401526020810190506104e0565b50505050905090810190601f1680156105285780820380516001836020036101000a031916815260200191505b5092505050602060405180830381600087803b15801561054757600080fd5b505af115801561055b573d6000803e3d6000fd5b505050506040513d602081101561057157600080fd5b810190808051906020019092919050505092508273ffffffffffffffffffffffffffffffffffffffff166313db93466040518163ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401602060405180830381600087803b1580156105e857600080fd5b505af11580156105fc573d6000803e3d6000fd5b505050506040513d602081101561061257600080fd5b810190808051906020019092919050505091508173ffffffffffffffffffffffffffffffffffffffff1663e942b5168a6040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808060200180602001838103835260028152602001807f6964000000000000000000000000000000000000000000000000000000000000815250602001838103825284818151815260200191508051906020019080838360005b838110156106e55780820151818401526020810190506106ca565b50505050905090810190601f1680156107125780820380516001836020036101000a031916815260200191505b509350505050600060405180830381600087803b15801561073257600080fd5b505af1158015610746573d6000803e3d6000fd5b505050508173ffffffffffffffffffffffffffffffffffffffff1663e942b516896040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808060200180602001838103835260088152602001807f6964656e74697479000000000000000000000000000000000000000000000000815250602001838103825284818151815260200191508051906020019080838360005b8381101561080a5780820151818401526020810190506107ef565b50505050905090810190601f1680156108375780820380516001836020036101000a031916815260200191505b509350505050600060405180830381600087803b15801561085757600080fd5b505af115801561086b573d6000803e3d6000fd5b505050508173ffffffffffffffffffffffffffffffffffffffff1663e942b516886040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808060200180602001838103835260048152602001807f6e616d6500000000000000000000000000000000000000000000000000000000815250602001838103825284818151815260200191508051906020019080838360005b8381101561092f578082015181840152602081019050610914565b50505050905090810190601f16801561095c5780820380516001836020036101000a031916815260200191505b509350505050600060405180830381600087803b15801561097c57600080fd5b505af1158015610990573d6000803e3d6000fd5b505050508173ffffffffffffffffffffffffffffffffffffffff1663e942b516876040518263ffffffff167c01000000000000000000000000000000000000000000000000000000000281526004018080602001806020018381038352600b8152602001807f6163636f756e7454797065000000000000000000000000000000000000000000815250602001838103825284818151815260200191508051906020019080838360005b83811015610a54578082015181840152602081019050610a39565b50505050905090810190601f168015610a815780820380516001836020036101000a031916815260200191505b509350505050600060405180830381600087803b158015610aa157600080fd5b505af1158015610ab5573d6000803e3d6000fd5b505050508173ffffffffffffffffffffffffffffffffffffffff1663e942b516866040518263ffffffff167c01000000000000000000000000000000000000000000000000000000000281526004018080602001806020018381038352600b8152602001807f6163636f756e7448617368000000000000000000000000000000000000000000815250602001838103825284818151815260200191508051906020019080838360005b83811015610b79578082015181840152602081019050610b5e565b50505050905090810190601f168015610ba65780820380516001836020036101000a031916815260200191505b509350505050600060405180830381600087803b158015610bc657600080fd5b505af1158015610bda573d6000803e3d6000fd5b505050508273ffffffffffffffffffffffffffffffffffffffff1663a815ff158a846040518363ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040180806020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001828103825284818151815260200191508051906020019080838360005b83811015610c99578082015181840152602081019050610c7e565b50505050905090810190601f168015610cc65780820380516001836020036101000a031916815260200191505b509350505050602060405180830381600087803b158015610ce657600080fd5b505af1158015610cfa573d6000803e3d6000fd5b505050506040513d6020811015610d1057600080fd5b810190808051906020019092919050505090507fb103249d88cd818b10c5cd6889874103a7699c5834cb078d8f35925dca8a62d6816040518082815260200191505060405180910390a180935050505095945050505050565b600060608060608060006060806060806000806000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673", "ffffffffffffffffffffffffffffffffffffffff1663f23f63c96040805190810160405280600a81526020017f6b765f6163636f756e74000000000000000000000000000000000000000000008152506040518263ffffffff167c01000000000000000000000000000000000000000000000000000000000281526004018080602001828103825283818151815260200191508051906020019080838360005b83811015610e5a578082015181840152602081019050610e3f565b50505050905090810190601f168015610e875780820380516001836020036101000a031916815260200191505b5092505050602060405180830381600087803b158015610ea657600080fd5b505af1158015610eba573d6000803e3d6000fd5b505050506040513d6020811015610ed057600080fd5b81019080805190602001909291905050509650600091508673ffffffffffffffffffffffffffffffffffffffff1663693ec85e8e6040518263ffffffff167c01000000000000000000000000000000000000000000000000000000000281526004018080602001828103825283818151815260200191508051906020019080838360005b83811015610f6f578082015181840152602081019050610f54565b50505050905090810190601f168015610f9c5780820380516001836020036101000a031916815260200191505b50925050506040805180830381600087803b158015610fba57600080fd5b505af1158015610fce573d6000803e3d6000fd5b505050506040513d6040811015610fe457600080fd5b810190808051906020019092919080519060200190929190505050809250819350505081156114da578073ffffffffffffffffffffffffffffffffffffffff16639c981fcb6040518163ffffffff167c01000000000000000000000000000000000000000000000000000000000281526004018080602001828103825260088152602001807f6964656e74697479000000000000000000000000000000000000000000000000815250602001915050600060405180830381600087803b1580156110ad57600080fd5b505af11580156110c1573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f8201168201806040525060208110156110eb57600080fd5b81019080805164010000000081111561110357600080fd5b8281019050602081018481111561111957600080fd5b815185600182028301116401000000008211171561113657600080fd5b505092919050505095508073ffffffffffffffffffffffffffffffffffffffff16639c981fcb6040518163ffffffff167c01000000000000000000000000000000000000000000000000000000000281526004018080602001828103825260048152602001807f6e616d6500000000000000000000000000000000000000000000000000000000815250602001915050600060405180830381600087803b1580156111e057600080fd5b505af11580156111f4573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f82011682018060405250602081101561121e57600080fd5b81019080805164010000000081111561123657600080fd5b8281019050602081018481111561124c57600080fd5b815185600182028301116401000000008211171561126957600080fd5b505092919050505094508073ffffffffffffffffffffffffffffffffffffffff16639c981fcb6040518163ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040180806020018281038252600b8152602001807f6163636f756e7454797065000000000000000000000000000000000000000000815250602001915050600060405180830381600087803b15801561131357600080fd5b505af1158015611327573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f82011682018060405250602081101561135157600080fd5b81019080805164010000000081111561136957600080fd5b8281019050602081018481111561137f57600080fd5b815185600182028301116401000000008211171561139c57600080fd5b505092919050505093508073ffffffffffffffffffffffffffffffffffffffff16639c981fcb6040518163ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040180806020018281038252600b8152602001807f6163636f756e7448617368000000000000000000000000000000000000000000815250602001915050600060405180830381600087803b15801561144657600080fd5b505af115801561145a573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f82011682018060405250602081101561148457600080fd5b81019080805164010000000081111561149c57600080fd5b828101905060208101848111156114b257600080fd5b81518560018202830111640100000000821117156114cf57600080fd5b505092919050505092505b81868686869b509b509b509b509b5050505050505050919395909294505600a165627a7a72305820e9a580e1803b0150a0c41a3f8b8503f4a82cc0d80b0d8cdd5e180b34c46e751c0029"};

    public static final String BINARY = org.fisco.bcos.sdk.utils.StringUtils.joinAll("", BINARY_ARRAY);

    public static final String[] SM_BINARY_ARRAY = {"608060405234801561001057600080fd5b506110106000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663c92a78016040805190810160405280600a81526020017f6b765f6163636f756e74000000000000000000000000000000000000000000008152506040518263ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040180806020018060200180602001848103845285818151815260200191508051906020019080838360005b8381101561013957808201518184015260208101905061011e565b50505050905090810190601f1680156101665780820380516001836020036101000a031916815260200191505b50848103835260028152602001807f6964000000000000000000000000000000000000000000000000000000000000815250602001848103825260258152602001807f6964656e746974792c6e616d652c6163636f756e74547970652c6163636f756e81526020017f7448617368000000000000000000000000000000000000000000000000000000815250604001945050505050602060405180830381600087803b15801561021557600080fd5b505af1158015610229573d6000803e3d6000fd5b505050506040513d602081101561023f57600080fd5b810190808051906020019092919050505050611525806102606000396000f30060806040526004361061004c576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680637b1b8e0314610051578063c0ab6a4c14610282575b600080fd5b34801561005d57600080fd5b506100b8600480360381019080803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290505050610417565b604051808615151515815260200180602001806020018060200180602001858103855289818151815260200191508051906020019080838360005b8381101561010e5780820151818401526020810190506100f3565b50505050905090810190601f16801561013b5780820380516001836020036101000a031916815260200191505b50858103845288818151815260200191508051906020019080838360005b83811015610174578082015181840152602081019050610159565b50505050905090810190601f1680156101a15780820380516001836020036101000a031916815260200191505b50858103835287818151815260200191508051906020019080838360005b838110156101da5780820151818401526020810190506101bf565b50505050905090810190601f1680156102075780820380516001836020036101000a031916815260200191505b50858103825286818151815260200191508051906020019080838360005b83811015610240578082015181840152602081019050610225565b50505050905090810190601f16801561026d5780820380516001836020036101000a031916815260200191505b50995050505050505050505060405180910390f35b34801561028e57600080fd5b50610401600480360381019080803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290505050610ba7565b6040518082815260200191505060405180910390f35b600060608060608060006060806060806000806000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166359a48b656040805190810160405280600a81526020017f6b765f6163636f756e74000000000000000000000000000000000000000000008152506040518263ffffffff167c01000000000000000000000000000000000000000000000000000000000281526004018080602001828103825283818151815260200191508051906020019080838360005b838110156105085780820151818401526020810190506104ed565b50505050905090810190601f1680156105355780820380516001836020036101000a031916815260200191505b5092505050602060405180830381600087803b15801561055457600080fd5b505af1158015610568573d6000803e3d6000fd5b505050506040513d602081101561057e57600080fd5b81019080805190602001909291905050509650600091508673ffffffffffffffffffffffffffffffffffffffff16637b1b8e038e6040518263ffffffff167c01000000000000000000000000000000000000000000000000000000000281526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561061d578082015181840152602081019050610602565b50505050905090810190601f16801561064a5780820380516001836020036101000a031916815260200191505b50925050506040805180830381600087803b15801561066857600080fd5b505af115801561067c573d6000803e3d6000fd5b505050506040513d604081101561069257600080fd5b81019080805190602001909291908051906020019092919050505080925081935050508115610b88578073ffffffffffffffffffffffffffffffffffffffff16639bca41e86040518163ffffffff167c01000000000000000000000000000000000000000000000000000000000281526004018080602001828103825260088152602001807f6964656e74697479000000000000000000000000000000000000000000000000815250602001915050600060405180830381600087803b15801561075b57600080fd5b505af115801561076f573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f82011682018060405250602081101561079957600080fd5b8101908080516401000000008111156107b157600080fd5b828101905060208101848111156107c757600080fd5b81518560018202830111640100000000821117156107e457600080fd5b505092919050505095508073ffffffffffffffffffffffffffffffffffffffff16639bca41e86040518163ffffffff167c01000000000000000000000000000000000000000000000000000000000281526004018080602001828103825260048152602001807f6e616d6500000000000000000000000000000000000000000000000000000000815250602001915050600060405180830381600087803b15801561088e57600080fd5b505af11580156108a2573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f8201168201806040525060208110156108cc57600080fd5b8101908080516401000000008111156108e457600080fd5b828101905060208101848111156108fa57600080fd5b815185600182028301116401000000008211171561091757600080fd5b505092919050505094508073ffffffffffffffffffffffffffffffffffffffff16639bca41e86040518163ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040180806020018281038252600b8152602001807f6163636f756e7454797065000000000000000000000000000000000000000000815250602001915050600060405180830381600087803b1580156109c157600080fd5b505af11580156109d5573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f8201168201806040525060208110156109ff57600080fd5b810190808051640100000000811115610a1757600080fd5b82810190506020810184811115610a2d57600080fd5b8151856001820283011164010000000082111715610a4a57600080fd5b505092919050505093508073ffffffffffffffffffffffffffffffffffffffff16639bca41e86040518163ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040180806020018281038252600b8152602001807f6163636f756e7448617368000000000000000000000000000000000000000000815250602001915050600060405180830381600087803b158015610af457600080fd5b505af1158015610b08573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f820116820180604052506020811015610b3257600080fd5b810190808051640100000000811115610b4a57600080fd5b82810190506020810184811115610b6057600080fd5b8151856001820283011164010000000082111715610b7d57600080fd5b505092919050505092505b81868686869b509b509b509b509b505050505050505091939590929450565b6000806000806000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166359a48b656040805190810160405280600a81526020017f6b765f6163636f756e74000000000000000000000000000000000000000000008152506040518263ffffffff167c01000000000000000000000000000000000000000000000000000000000281526004018080602001828103825283818151815260200191508051906020019080838360005b83811015610c8b578082015181840152602081019050610c70565b50505050905090810190601f168015610cb85780820380516001836020036101000a031916815260200191505b5092505050602060405180830381600087803b158015610cd757600080fd5b505af1158015610ceb573d6000803e3d6000fd5b505050506040513d6020811015610d0157600080fd5b810190808051906020019092919050505092508273ffffffffffffffffffffffffffffffffffffffff16635887ab246040518163ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401602060405180830381600087803b158015610d7857600080fd5b505af1158015610d8c573d6000803e3d6000fd5b505050506040513d6020811015610da2576000", "80fd5b810190808051906020019092919050505091508173ffffffffffffffffffffffffffffffffffffffff16631a391cb48a6040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808060200180602001838103835260028152602001807f6964000000000000000000000000000000000000000000000000000000000000815250602001838103825284818151815260200191508051906020019080838360005b83811015610e75578082015181840152602081019050610e5a565b50505050905090810190601f168015610ea25780820380516001836020036101000a031916815260200191505b509350505050600060405180830381600087803b158015610ec257600080fd5b505af1158015610ed6573d6000803e3d6000fd5b505050508173ffffffffffffffffffffffffffffffffffffffff16631a391cb4896040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808060200180602001838103835260088152602001807f6964656e74697479000000000000000000000000000000000000000000000000815250602001838103825284818151815260200191508051906020019080838360005b83811015610f9a578082015181840152602081019050610f7f565b50505050905090810190601f168015610fc75780820380516001836020036101000a031916815260200191505b509350505050600060405180830381600087803b158015610fe757600080fd5b505af1158015610ffb573d6000803e3d6000fd5b505050508173ffffffffffffffffffffffffffffffffffffffff16631a391cb4886040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808060200180602001838103835260048152602001807f6e616d6500000000000000000000000000000000000000000000000000000000815250602001838103825284818151815260200191508051906020019080838360005b838110156110bf5780820151818401526020810190506110a4565b50505050905090810190601f1680156110ec5780820380516001836020036101000a031916815260200191505b509350505050600060405180830381600087803b15801561110c57600080fd5b505af1158015611120573d6000803e3d6000fd5b505050508173ffffffffffffffffffffffffffffffffffffffff16631a391cb4876040518263ffffffff167c01000000000000000000000000000000000000000000000000000000000281526004018080602001806020018381038352600b8152602001807f6163636f756e7454797065000000000000000000000000000000000000000000815250602001838103825284818151815260200191508051906020019080838360005b838110156111e45780820151818401526020810190506111c9565b50505050905090810190601f1680156112115780820380516001836020036101000a031916815260200191505b509350505050600060405180830381600087803b15801561123157600080fd5b505af1158015611245573d6000803e3d6000fd5b505050508173ffffffffffffffffffffffffffffffffffffffff16631a391cb4866040518263ffffffff167c01000000000000000000000000000000000000000000000000000000000281526004018080602001806020018381038352600b8152602001807f6163636f756e7448617368000000000000000000000000000000000000000000815250602001838103825284818151815260200191508051906020019080838360005b838110156113095780820151818401526020810190506112ee565b50505050905090810190601f1680156113365780820380516001836020036101000a031916815260200191505b509350505050600060405180830381600087803b15801561135657600080fd5b505af115801561136a573d6000803e3d6000fd5b505050508273ffffffffffffffffffffffffffffffffffffffff1663517c4dd98a846040518363ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040180806020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001828103825284818151815260200191508051906020019080838360005b8381101561142957808201518184015260208101905061140e565b50505050905090810190601f1680156114565780820380516001836020036101000a031916815260200191505b509350505050602060405180830381600087803b15801561147657600080fd5b505af115801561148a573d6000803e3d6000fd5b505050506040513d60208110156114a057600080fd5b810190808051906020019092919050505090507f8425f908744b84757cbeb3eda153cd3971c5a3fdecc6e6d18a6a223d52ca763f816040518082815260200191505060405180910390a1809350505050959450505050505600a165627a7a72305820b9b9d73b5a73ba981226aef2cd588f5156e841845856d0f6dfe5cb14fb6df7db0029"};

    public static final String SM_BINARY = org.fisco.bcos.sdk.utils.StringUtils.joinAll("", SM_BINARY_ARRAY);

    public static final String[] ABI_ARRAY = {"[{\"constant\":false,\"inputs\":[{\"name\":\"id\",\"type\":\"string\"},{\"name\":\"identity\",\"type\":\"string\"},{\"name\":\"name\",\"type\":\"string\"},{\"name\":\"accountType\",\"type\":\"string\"},{\"name\":\"accountHash\",\"type\":\"string\"}],\"name\":\"set\",\"outputs\":[{\"name\":\"\",\"type\":\"int256\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"id\",\"type\":\"string\"}],\"name\":\"get\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"},{\"name\":\"\",\"type\":\"string\"},{\"name\":\"\",\"type\":\"string\"},{\"name\":\"\",\"type\":\"string\"},{\"name\":\"\",\"type\":\"string\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"count\",\"type\":\"int256\"}],\"name\":\"SetResult\",\"type\":\"event\"}]"};

    public static final String ABI = org.fisco.bcos.sdk.utils.StringUtils.joinAll("", ABI_ARRAY);

    public static final String FUNC_SET = "set";

    public static final String FUNC_GET = "get";

    public static final Event SETRESULT_EVENT = new Event("SetResult",
            Arrays.<TypeReference<?>>asList(new TypeReference<Int256>() {
            }));
    ;

    protected AccountKV(String contractAddress, Client client, CryptoKeyPair credential) {
        super(getBinary(client.getCryptoSuite()), contractAddress, client, credential);
    }

    public static String getBinary(CryptoSuite cryptoSuite) {
        return (cryptoSuite.getCryptoTypeConfig() == CryptoType.ECDSA_TYPE ? BINARY : SM_BINARY);
    }

    public TransactionReceipt set(String id, String identity, String name, String accountType, String accountHash) {
        final Function function = new Function(
                FUNC_SET,
                Arrays.<Type>asList(new org.fisco.bcos.sdk.abi.datatypes.Utf8String(id),
                        new org.fisco.bcos.sdk.abi.datatypes.Utf8String(identity),
                        new org.fisco.bcos.sdk.abi.datatypes.Utf8String(name),
                        new org.fisco.bcos.sdk.abi.datatypes.Utf8String(accountType),
                        new org.fisco.bcos.sdk.abi.datatypes.Utf8String(accountHash)),
                Collections.<TypeReference<?>>emptyList());
        return executeTransaction(function);
    }

    public byte[] set(String id, String identity, String name, String accountType, String accountHash, TransactionCallback callback) {
        final Function function = new Function(
                FUNC_SET,
                Arrays.<Type>asList(new org.fisco.bcos.sdk.abi.datatypes.Utf8String(id),
                        new org.fisco.bcos.sdk.abi.datatypes.Utf8String(identity),
                        new org.fisco.bcos.sdk.abi.datatypes.Utf8String(name),
                        new org.fisco.bcos.sdk.abi.datatypes.Utf8String(accountType),
                        new org.fisco.bcos.sdk.abi.datatypes.Utf8String(accountHash)),
                Collections.<TypeReference<?>>emptyList());
        return asyncExecuteTransaction(function, callback);
    }

    public String getSignedTransactionForSet(String id, String identity, String name, String accountType, String accountHash) {
        final Function function = new Function(
                FUNC_SET,
                Arrays.<Type>asList(new org.fisco.bcos.sdk.abi.datatypes.Utf8String(id),
                        new org.fisco.bcos.sdk.abi.datatypes.Utf8String(identity),
                        new org.fisco.bcos.sdk.abi.datatypes.Utf8String(name),
                        new org.fisco.bcos.sdk.abi.datatypes.Utf8String(accountType),
                        new org.fisco.bcos.sdk.abi.datatypes.Utf8String(accountHash)),
                Collections.<TypeReference<?>>emptyList());
        return createSignedTransaction(function);
    }

    public Tuple5<String, String, String, String, String> getSetInput(TransactionReceipt transactionReceipt) {
        String data = transactionReceipt.getInput().substring(10);
        final Function function = new Function(FUNC_SET,
                Arrays.<Type>asList(),
                Arrays.<TypeReference<?>>asList(new TypeReference<Utf8String>() {
                }, new TypeReference<Utf8String>() {
                }, new TypeReference<Utf8String>() {
                }, new TypeReference<Utf8String>() {
                }, new TypeReference<Utf8String>() {
                }));
        List<Type> results = FunctionReturnDecoder.decode(data, function.getOutputParameters());
        return new Tuple5<String, String, String, String, String>(

                (String) results.get(0).getValue(),
                (String) results.get(1).getValue(),
                (String) results.get(2).getValue(),
                (String) results.get(3).getValue(),
                (String) results.get(4).getValue()
        );
    }

    public Tuple1<BigInteger> getSetOutput(TransactionReceipt transactionReceipt) {
        String data = transactionReceipt.getOutput();
        final Function function = new Function(FUNC_SET,
                Arrays.<Type>asList(),
                Arrays.<TypeReference<?>>asList(new TypeReference<Int256>() {
                }));
        List<Type> results = FunctionReturnDecoder.decode(data, function.getOutputParameters());
        return new Tuple1<BigInteger>(

                (BigInteger) results.get(0).getValue()
        );
    }

    public Tuple5<Boolean, String, String, String, String> get(String id) throws ContractException {
        final Function function = new Function(FUNC_GET,
                Arrays.<Type>asList(new org.fisco.bcos.sdk.abi.datatypes.Utf8String(id)),
                Arrays.<TypeReference<?>>asList(new TypeReference<Bool>() {
                }, new TypeReference<Utf8String>() {
                }, new TypeReference<Utf8String>() {
                }, new TypeReference<Utf8String>() {
                }, new TypeReference<Utf8String>() {
                }));
        List<Type> results = executeCallWithMultipleValueReturn(function);
        return new Tuple5<Boolean, String, String, String, String>(
                (Boolean) results.get(0).getValue(),
                (String) results.get(1).getValue(),
                (String) results.get(2).getValue(),
                (String) results.get(3).getValue(),
                (String) results.get(4).getValue());
    }

    public List<SetResultEventResponse> getSetResultEvents(TransactionReceipt transactionReceipt) {
        List<Contract.EventValuesWithLog> valueList = extractEventParametersWithLog(SETRESULT_EVENT, transactionReceipt);
        ArrayList<SetResultEventResponse> responses = new ArrayList<SetResultEventResponse>(valueList.size());
        for (Contract.EventValuesWithLog eventValues : valueList) {
            SetResultEventResponse typedResponse = new SetResultEventResponse();
            typedResponse.log = eventValues.getLog();
            typedResponse.count = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue();
            responses.add(typedResponse);
        }
        return responses;
    }

    public void subscribeSetResultEvent(String fromBlock, String toBlock, List<String> otherTopics, EventCallback callback) {
        String topic0 = eventEncoder.encode(SETRESULT_EVENT);
        subscribeEvent(ABI, BINARY, topic0, fromBlock, toBlock, otherTopics, callback);
    }

    public void subscribeSetResultEvent(EventCallback callback) {
        String topic0 = eventEncoder.encode(SETRESULT_EVENT);
        subscribeEvent(ABI, BINARY, topic0, callback);
    }

    public static AccountKV load(String contractAddress, Client client, CryptoKeyPair credential) {
        return new AccountKV(contractAddress, client, credential);
    }

    public static AccountKV deploy(Client client, CryptoKeyPair credential) throws ContractException {
        return deploy(AccountKV.class, client, credential, getBinary(client.getCryptoSuite()), "");
    }

    public static class SetResultEventResponse {
        public TransactionReceipt.Logs log;

        public BigInteger count;
    }
}
